package com.cloudptt.wp.ui.more;
//Download by htp://www.codefans.net


import android.app.Activity;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.cloudptt.api.comm.CommInfo;
import com.cloudptt.api.models.VersionInfo;
import com.cloudptt.api.product.Product;
import com.cloudptt.wp.R;
import com.cloudptt.wp.ScreenManager;
import com.cloudptt.wp.SysApplication;
import com.mcptt.config.model.McIdInfo;
import com.mcptt.config.model.BootStrapSvrInfo;

public class SysInfoActivity extends Activity implements OnClickListener {
	
	private TextView returnBtn; 
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		Window window = getWindow();
		window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
		//window.setStatusBarColor(getResources().getColor(R.color.app_theme_color_primary));
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_userinfo);
		
		getActionBar().setBackgroundDrawable(getResources().getDrawable(R.color.app_theme_color_primary));
		getActionBar().hide();

		
		TextView userTypeTv = (TextView)findViewById(R.id.userTypeTv);
		TextView userNameTv = (TextView)findViewById(R.id.userNameTv);
		TextView userNumTv = (TextView)findViewById(R.id.userNumTv);
		TextView userIdTv = (TextView)findViewById(R.id.userIdTv);
		TextView serverTv = (TextView)findViewById(R.id.serverTv);

		SysApplication app = ((SysApplication) getApplicationContext());
		Product product = app.getProduct();
		McIdInfo info = product.getSysConfig().getMcInfo();
		String str = this.getString(R.string.user_type_prefix) + this.getString(R.string.user_type_intel);
		userTypeTv.setText(str);

		String name = info.getName();
		str = this.getString(R.string.user_name_prefix) + name;
		userNameTv.setText(str);

		String num = info.getAddrId();
		str = this.getString(R.string.user_num_prefix) + num;
		userNumTv.setText(str);

		String id = info.getAddrId();
		str = this.getString(R.string.user_id_prefix) + id;
		userIdTv.setText(str);

		BootStrapSvrInfo serverInfo = product.getSysConfig().getBootStrapSvr();
		String ip = serverInfo.getServerIp();
		str = this.getString(R.string.user_svr_prefix) + ip;
		serverTv.setText(str);

		TextView tv = (TextView) findViewById(R.id.titleTv);
		tv.setText(R.string.settings_user);

		ScreenManager.getScreenManager().pushActivity(this);
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		
		if(android.R.id.home == item.getItemId()){
			finish();
			return true;
		}
		
		return super.onOptionsItemSelected(item);
	}
	
	public void onClick(View v) {
//		int id = v.getId();
//		if(id == R.id.back_up_icon)
//		{
//			this.finish();
//		}
	}

	/**
	 * 锟斤拷取锟芥本锟斤拷
	 * @return 锟斤拷前应锟矫的版本锟斤拷
	 */
	public String getVersion() {
	    try {
	    	VersionInfo verInfo = CommInfo.getVersionInfo(SysInfoActivity.this);
	        String version = verInfo.getName() + "(" + verInfo.getVersionCode() + ")";
	        return getString(R.string.current_version) + version;
	    } catch (Exception e) {
	        e.printStackTrace();
	        return "";
	    }
	}

	public void login_back(View v) {     
		this.finish();
	}  
	
}
